package top.soulblack.purchasesale.service;

import org.springframework.stereotype.Service;
import top.soulblack.purchasesale.mapper.CustomerMapper;
import top.soulblack.purchasesale.model.Customer;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: 陈俊宇
 * @Description:
 * @Date: Create in 15:12 2019/8/30
 */

@Service
public class CustomerService {
    @Resource
    private CustomerMapper customerMapper;

    public List<Customer> selectAll(){
        return customerMapper.selectAll();
    }

    public void addCustomer(Customer customer){
        customerMapper.addCustomer(customer);
        return;
    }

    public boolean existCustomer(String name) {
        int num  = customerMapper.existCustomer(name);
        if (num == 1) {
            return true;
        }
        return false;

    }
    public List<Customer> selectForName(String customerName) {
        return customerMapper.selectForName(customerName);
    }

    public boolean deleteCustomer(Integer customersId) {
        int num = customerMapper.deleteById(customersId);
        if (num == 1) {
            return true;
        }
        return false;
    }

    public boolean updateCustomer(Customer customer) {
        int num = customerMapper.updateCustomer(customer);
        if (num == 1) {
            return true;
        }
        return false;
    }
}
